function lstinf$(a$,b$,c$)
  adra=1:adrb=1:blngt=len(b$):d$=""
  while adrb<=blngt
    if mid$ (a$,adra,1)=mid$ (b$,adrb,1) then:adrb+=1:end if
    adra=adra+1
    end while
  while mid$(a$,adra,1)<>left$(c$,1)
    d$=d$+mid$(a$,adra,1):adra=adra+1
    end while
  lstinf$=d$
  end function

function vldc(a$)
  t0$="!"+a$+".0.0.0."
  t1$=lstinf$(t0$,"!",".")
  t2$=lstinf$(t0$,".",".")
  t3=10^(len(t2$))
  vldc=val(t1$)+(val(t2$)/t3)
  end function

dim chfq[16],chvl[16]

finp$="_.csv"
if argc>2 then:finp$=argv(2):end if

print"56676D20"
print"FFFFFF00"
print"61010000"
print"0000000000000000"
print"DE050000"
print"002B0500"
print"A7000000"
print"00000000"
print"32000000"
print"000000000000000000000000"
print"8C000000"
print"00000000000000000000000000000000"
print"00000000000000000000000000000000"
print"00000000000000000000000000000000"
print"00000000000000000000000000000000"
print"0000000000000000"
print"00004000"
print"00000000000000000000000000000000"
print"00000000000000000000000000000000"
print"00000000000000000000000000000000"
print"000000000000000000000000"
print


'print"B30000"
'print"B3168F B315FF B31477"
'print"B30000 B30200 B30700 B30C20"
'print"B311F7 B31200 "
'print"B30100 B30600 B30A00 "
'print"B320FF B321FF B322FF B323FF" 
'print"B324FF B325FF B326FF B327FF"
'print"B32800 B32900 B32A00 B32B00" 
'print"B32C00 B32D00 B32E00 B32F00"
'print"B30A80 B30D16 B30A00 B302F3"

print"B30000"
print"B3168F B315FF B31477"
print"B30000 B30200 B30700 B30C20"
print"B311F7 B31200"
print"B30100 B30600 B30A00"
print"B32000 B32111 B32222 B32333"
print"B32444 B32555 B32666 B32777"
print"B32888 B32999 B32AAA B32BBB"
print"B32CCC B32DDD B32EEE B32FFF"
print"B30A80 B30D59 B30A00"
print"B3013F B302F5"
print"B3030B"
print"B3013F"
print"B30486"
print"B3063F B307F5 B30872"
print"B3063F B30986"
print"B30BFF B30A80 B30B3F B30E87"
print"B3103F B311F5 "
print"B31215 B31380"
print"B3103F"

print

lct=0

open finp$ for input as #1
while eof(1)=0
  file input #1,txrd$
  setcaption("b:"+str$(lct)):lct+=1
  if mid$(txrd$,1,1)="[" then:
    if mid$(txrd$,2,1)="f" then:
      chid=val(mid$(txrd$,3,2))
      chid=chid mod 4 'rp2c33 has 4 channels
      chfqv=vldc(lstinf$(txrd$,":","]"))
      if chid=2 then:chfqv+=1:end if '- channel 3 is 1 octave lower
      chfqv2=(2047-int(31.25*2^(8-chfqv)))
      if chfqv2>2047 then:chfqv2=2047:end if
      if chfqv2<0 then:chfqv2=0:end if
      chchrfq$=right$("000"+hex$(chfqv2),3)
      txrgo$="B3"+right$("00"+hex$(4+5*chid),2)+"8"+mid$(chchrfq$,1,1)
      txrgo$+=" B3"+right$("00"+hex$(3+5*chid),2)+mid$(chchrfq$,2,2)
      print ucase$(txrgo$)
      end if
    if mid$(txrd$,2,1)="v" then:
      chid=val(mid$(txrd$,3,2))
      chid=chid mod 4 'rp2c33 has 4 channels
      chvlv=vldc(lstinf$(txrd$,":","]"))*0x40
      chchrvl$=right$("00"+hex$(chvlv),2)
      txrgo$="B3"+right$("00"+hex$(1+5*chid),2)+chchrvl$
      print ucase$(txrgo$)
      end if
    if mid$(txrd$,2,3)="wvb" then:
      wvblv=vldc(lstinf$(txrd$,":","]"))
      wvblv2=wvblv*44100
      wvblv3a=wvblv2 mod 65536
      wvblv3b=int(wvblv2/65536)
      wvblv3as$=ucase$(right$("0000"+hex$(wvblv3a),4))
      for ii=1 to wvblv3b:print"61FFFF":next
      print "61"+mid$(wvblv3as$,3,2)+mid$(wvblv3as$,1,2)
      'print"(debug:delay="+str$(wvblv2)+")" '- apagar

      end if

    end if
  wend
print:print "66":print
close #1


